home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / AmigaTalk / testfiles / TestKeyboard < prev    next >
Encoding:
Text File  |  2004-01-31  |  1.2 KB  |  55 lines

  1. scr <- Screen new
  2. scr setScreenModeID: 16r40D20001
  3. scr            open: 'TestScreen'
  4.  
  5. win <- Window new: 'Test Key Class:'
  6.  
  7. win setFlags:       16r100F
  8. win setIDCMPFlags:  16r140
  9. win openOnScreen:   scr
  10.  
  11. key <- Key new
  12. key initialize
  13.  
  14. key registerTo: win
  15.  
  16. scr screenToFront
  17.  
  18. itxt <-IText new: 'Press & release a key (or combination)...'
  19.  
  20. itxt setPens:         5 @ 2
  21. itxt setITextOrigin:  0 @ 0
  22.  
  23. win printIText: itxt at: 100 @ 20
  24.  
  25. userKey <- key getRawKey
  26.  
  27. p1 <- Painter new: win
  28. p1 setAPen: 3
  29.  
  30. result <- ('You pressed key number ', userKey asString, ' (Raw Key value),')
  31.  
  32. p1 drawText: result at: 100@35
  33.  
  34. asciiVal <- key asciiToString: (key translateKey: userKey)
  35.  
  36. result <- ('which translates to "', asciiVal, '" (Cooked Key value);')
  37.  
  38. p1 drawText: result at: 100@45
  39.  
  40. result <- ('The qualifiers (value) was ', ((key keyQualifiers) asString))
  41.  
  42. p1 drawText: result at: 100@55
  43.  
  44. p1 drawText: 'Press another key...' at: 100@65
  45. userKey <- key getVanillaKey
  46.  
  47. result <- ('You pressed "', (key asciiToString: userKey), '" (Vanilla Key value),')
  48.  
  49. p1 drawText: result at: 100@75
  50.  
  51. p1 drawText: 'type:  "win close", then "scr close" in the Command' at: 100@170
  52. p1 drawText: 'String Gadget to clean things up!' at: 100@180
  53.  
  54. itxt dispose
  55.